import publicForm from "@/components/public/el-form.vue"; //弹框form
import TableData from "@/components/HntManage/el-tables"; //主页面列表
import formJs from "./regexDetail.js"; //新增弹框配置项
import {
    getJobbriefingdataPageList //详情

} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "projectId",
        "status",
        "statusNum",
        "dataFid",
        "currentRow",
        "projectName",
        "fCompanyid"
    ],
    data() {
        return {
            visible: "",
            title: "本周工作简报",
            btnStatus: [],
            dialogHeight: null,
            activeIndex: "1",
            formObj: formJs.formObj,
            table_config: formJs.dialog_config,
            tableData: [],
            currntData: null,
            dataInfo: null,
            formData: {
                fId: "", //传此表示修改
                userId: "", //当前登录人id
                userName: "", //当前登录人名称
                fProjectname: "", //当前登录人项目名称(如果是项目部的保存接口,传这个人的所在上级的项目id)
                fProjectid: "", //当前登录人项目ID
                fCompanyname: "", //当前登录人标段名称
                fCompanyid: "", //当前登录人标段ID
                fConstructionpoject: "", //工程建设项目
                fConstructionpojectid: "", //工程建设项目id
                fUnit: "", //编制单位
                fUnitid: "", //编制单位id
                fAffiliationyear: this.common.getYear(0), //隶属年度
                fAffiliationmonth: this.common.getMonth(0), //隶属月份
                fMonthreport: "", //月报其次
                fWeaveexplain: "", //编制说明
                fWeaveid: "", //编制人id
                fWeavename: "", //编制人姓名
                fWeavedates: this.common.getDay(0), //编制日期
                fMonthfileurl: "",
                fSubcheckid: "", //提交审核人id
                fSubcheckname: "", //提交审核人姓名
                recordfiles: [],
            },
            loading: false,
            formDatafileList: [], //工作计划资料
            fCcpeopleData: [], //计划传阅人
            fFinishccpeopleData: [], //完成传阅人
            monthExamine: formJs.monthExamine, //计划审核
            monthExamineData: {
                fId: "", //修改与保存都必须传
                fCheckstatus: "", //审核结果(内容详实,审核通过。)(内容不实，重新上报。)  如审核未通过 打回上一级 状态为”已打回“ 已打回状态下只能删除不能修改
                fCheckdescription: "", //审核说明
                fCheckid: "", //审核人id
                fCheckname: "", //审核人姓名
                fCheckdates: this.common.getDay(0), //审核时间
                userId: "", //当前登录人id
                userName: "", //当前登录人姓名

            }, //审核
            btnShow: true,
            FinishfileList: [], //工作计划资料
            fFinishccpeople: [], //计划传阅人
            currentStatus: null,
        };
    },
    components: {
        publicForm,
        TableData
        // commonPage
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        status: {
            handler(newVal) {
                if (newVal) {
                    this.btnStatus = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    // this.edit(newVal);
                }
            },
            immediate: true,
        },
        dataFid: {
            handler(newVal) {
                if (newVal) {
                    // console.log("详情页获得当前行id数据", newVal);

                    // this.currntData = newVal;

                    // this.currentStatus = newVal;
                    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));

                    var data = {
                        fSubunitid: newVal, //公司ID
                        userId: this.userInfo.userId, //登录人id
                        modelType: 2, //
                        page: 1,
                        pageSize: 100 //分页查询每页显示条数
                    }
                    this.getDetail(data);
                }
            },
            immediate: true,
        },
        fCompanyid: {
            handler(newVal) {
                if (newVal) {
                    // this.currentStatus = newVal;
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"));

        if (this.statusNum == 7) { //查看
            this.btnShow = false
            this.formObj.map((item) => {
                item.disabled = true;
            });
            this.formObj[6].uploadSelect = false;
        }
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        closeDialog() {
            this.$emit("close");
        },
        rowChange(val) {
            this.monthExamineData = val;
            this.formData = val;
            this.formDatafileList = val.fPatrolfileurllist
        },
        // 详情
        getDetail(data1) {
            this.loading = true
            getJobbriefingdataPageList(data1).then((res) => {
                this.loading = false;
                var data = res.data.pageInfo.list;
                this.dataInfo = data.fId
                this.formData = data[0];
                this.formDatafileList = data[0].fPatrolfileurllist
                this.tableData = data
            });
        },

    },
};